/*
2021-7-9
https://www.acwing.com/problem/content/3764/
*/

#include<iostream>
#include<cstring>

using namespace std;
const int N=2e5+10;
int cnt[N],a[N];

int main()
{
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    
    int T;
    cin>>T;
    
    while(T--)
    {
        int n,x;
        cin>>n;
        
        memset(cnt,0,4*(n+1));
        
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            cnt[a[i]]++;
        }
        
        int res=-1;
        
        for(int i=1;i<=n;i++)
            if(cnt[a[i]]==1)
                if(res==-1 || a[res]>a[i])
                    res=i;
        cout<<res<<endl;
    }
    
    return 0;
}
